<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%nbrb_custom_admittance}}".
 *
 * @property int $id
 * @property string $request_seq_no
 * @property string $req_name
 * @property string $req_cert_type
 * @property string $req_cert_no
 * @property string $req_phone
 * @property string $request_json
 * @property int $created_at
 * @property int $status
 * @property string $order_number
 * @property string $access_number
 *
 * @property NbrbAdditionalRecordApply $nbrbAdditionalRecordApply
 * @property NbrbFinalAuditApply $nbrbFinalAuditApply
 * @property NbrbLoanApply $nbrbLoanApply
 * @property NbrbPledgeInfoNotice $nbrbPledgeInfoNotice
 * @property NbrbUnderwriteApply $nbrbUnderwriteApply
 */
class NbrbCustomAdmittance extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%nbrb_custom_admittance}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['request_seq_no', 'req_name', 'req_cert_type', 'req_cert_no', 'req_phone', 'request_json', 'created_at', 'status', 'order_number', 'access_number'], 'required'],
            [['request_json'], 'string'],
            [['created_at', 'status'], 'integer'],
            [['request_seq_no', 'req_name', 'req_cert_no', 'order_number', 'access_number'], 'string', 'max' => 50],
            [['req_cert_type'], 'string', 'max' => 20],
            [['req_phone'], 'string', 'max' => 11],
            [['order_number'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'request_seq_no' => Yii::t('app', 'Request Seq No'),
            'req_name' => Yii::t('app', 'Req Name'),
            'req_cert_type' => Yii::t('app', 'Req Cert Type'),
            'req_cert_no' => Yii::t('app', 'Req Cert No'),
            'req_phone' => Yii::t('app', 'Req Phone'),
            'request_json' => Yii::t('app', 'Request Json'),
            'created_at' => Yii::t('app', 'Created At'),
            'status' => Yii::t('app', 'Status'),
            'order_number' => Yii::t('app', 'Order Number'),
            'access_number' => Yii::t('app', 'Access Number'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getNbrbAdditionalRecordApply()
    {
        return $this->hasOne(NbrbAdditionalRecordApply::className(), ['req_order_number' => 'order_number']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getNbrbFinalAuditApply()
    {
        return $this->hasOne(NbrbFinalAuditApply::className(), ['req_order_number' => 'order_number']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getNbrbLoanApply()
    {
        return $this->hasOne(NbrbLoanApply::className(), ['req_order_number' => 'order_number']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getNbrbPledgeInfoNotice()
    {
        return $this->hasOne(NbrbPledgeInfoNotice::className(), ['req_order_number' => 'order_number']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getNbrbUnderwriteApply()
    {
        return $this->hasOne(NbrbUnderwriteApply::className(), ['req_order_number' => 'order_number']);
    }
}
